﻿/*******************************************************************
 *     JameE
 *******************************************************************
  Copyright 2010 Clifford Champion and JameE contributors.
  
  This file is part of JameE.
  
  JameE is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  JameE is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with JameE.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************/
 
 
 
/// <reference path="~/Base/Classer.js" />
/// <reference path="~/Base/IncludeLoader.js" />

$include(
[
	"Engine/SceneObject.js"
],
function () {

	$class(
	"JameE.Assets.TextRegion : SceneObject",
	{
		/////////////////////
		// CONSTANTS
		/////////////


		/////////////////////
		// FIELDS
		/////////////
		_strText: null,
		_strColor: null,


		/////////////////////
		// CONSTRUCTORS
		/////////////
		_ctor: function () {
			this._strText = $argument("text", "string") || "";
			this._strColor = $argument("color", "string") || "#000000";
		},


		/////////////////////
		// METHODS
		/////////////
		setText: function (strText) {
			$require_type(strText, "string");
			this._strText = strText;
		},


		/////////////////////
		// METHODS: SceneObject
		/////////////
		draw: function (oContext) {
			if (this._strText.length === 0) {
				return;
			}

			// save state
			oContext.save();

			// modify state
			oContext.font = "10px Arial";
			oContext.fillStyle = this._strColor;

			// render
			oContext.fillText(this._strText, this._oPosition.fX, this._oPosition.fY);

			// restore state
			oContext.restore();
		}
	});

	$include_notify("Assets/Objects/TextRegion.js");

});